import { Flatten } from "../utils/array";

class Storage {
  static marketnftByStorage(marketnft) {
    sessionStorage.setItem("marketnft", JSON.stringify(marketnft));
  }

  static tranferByStorage(orderList) {
    sessionStorage.setItem("tranfer", JSON.stringify(orderList));
  }


  static orderListByStorage(orderList) {
    sessionStorage.setItem("orderList", JSON.stringify(orderList));
  }

  static classListByStorage(classList) {

    let res = Flatten(classList);
    sessionStorage.setItem("classList", JSON.stringify(res));
    state.classList = classList;
  }

 
  static getTranferList() {
    let json = sessionStorage.getItem("tranfer");
    if (!json) {
      return null;
    }
    return JSON.parse(json);
  }

  /**
   * 
   * @returns {Array}
   */
  static getMarketnft() {
    let json = sessionStorage.getItem("marketnft");
    if (!json) {
      return null;
    }
    console.log("res", typeof JSON.parse(json));
    return JSON.parse(json);
  }

  static getClassList() {
    let json = sessionStorage.getItem("classList");
    if (!json) {
      return null;
    }
    return JSON.parse(json);
  }

  static getOrderList() {
    let json = sessionStorage.getItem("orderList");
    if (!json) {
      return null;
    }
    return JSON.parse(json);
  } 
}

export { Storage }
